<template>
  <div class="common-table">
    <el-table :data="tableData" height="90%" stripe v-loading="config.loading">
     <el-table-column
        label="序号"
        width="85" >
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ (config.page-1)*20+scope.$index +1 }}</span>
        </template>
     </el-table-column>
     <el-table-column show-overflow-tooltip 
     v-for="item in tableLable" 
     :key="item.prop" 
     :label="item.label"
     :width="item.width ? item.width : 120"
      align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row[item.prop] }}</span>
        </template>
     </el-table-column>
     <el-table-column label="操作" width="150">
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="handleEdit(scope.row)">编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
      <el-pagination 
        class="manage-pagination" 
        layout="prev, pager, next" 
        :page-count="config.total" 
        :current-page.sync="config.page" 
      />
  </div>
</template>

<script>
export default {
  props:{
    tableData:Array,
    tableLable:Array,
    //接受配置
    config: Object
  },
  methods: {
    handleEdit(row) {
      this.$emit('edit', row)
    },
    handleDelete(row){
      this.$emit('del',row)
    },
    // 切换页码
    changePage(page) {
      this.$emit('changePage', page)
    }
  },
}
</script>

<style lang="scss" scoped>
.common-table{
   height: 550px;
  background-color: #fff;
  position: relative;
  .manage-pagination{
    position: absolute;
    bottom: 15px;
    right: 0;
  }
}
</style>